package myException;

import org.junit.Test;

public class MyException {
    /*
    栈溢出异常
     */
    @Test
    public void testStackOverflowError() {
        recursion();
    }

    public void recursion() {
        recursion();
    }

    /*
    下标越界异常
     */
    @Test
    public void testArrayIndexOutOfBoundsException() {
        int[] arr = {1, 2, 3, 4};
        System.out.println(arr[4]);
    }

    /*
    空指针异常
     */
    @Test
    public void testNullPointerException() {
        String str = null;
        System.out.println(str.length());
    }

    /*
    类型转换异常
     */
    @Test
    public void testClassCastException() {
        Object obj = new Object();
        String str = (String) obj;
    }

}
